package cn.lyjuan.android.demofive.frame.tpl;

import android.os.Handler;

import java.util.Map;

/**
 * Created by chad on 12/11/2017.
 */

public abstract class AbstractNetDataSource<T, E> implements IDataSource<E>
{
    protected IFetchDataListener listener;

    @Override
    public void fetchData(final boolean clear)
    {
        Map<String, Object> params = params();

        new Handler()
        {
        }.postDelayed(new Runnable()
        {
            @Override
            public void run()
            {
                if (null != listener)
                    listener.onFetchSucc("abc", clear);
            }
        }, 2000);
    }

    /**
     * 封装请求参数
     *
     * @return
     */
    protected abstract Map<String, Object> params();

    @Override
    public boolean isSucc(E e)
    {
        return false;
    }

    @Override
    public void setFetchDataListener(IFetchDataListener<E> listener)
    {
        // todo exist error
        this.listener = listener;
    }
}
